package com.aaa.whj.controller;

import com.aaa.whj.entity.TabProblem;
import com.aaa.whj.service.IProblemService;
import com.aaa.whj.service.impl.ProblemServiceImpl;
import com.util.LayData;
import com.util.PrintJsonData;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "problemServlet", value = "/problemServlet")
public class ProblemServlet extends HttpServlet {
    IProblemService iProblemService=new ProblemServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String method = req.getParameter("method");
        if(method==null){
            queryAll(req,resp);
        }
    }

    private void queryAll(HttpServletRequest req, HttpServletResponse resp) {
        List<TabProblem> tabProblem=iProblemService.queryAll();
        System.out.println("tabProblem = " + tabProblem);
        LayData success = LayData.success(tabProblem);
        PrintJsonData.printData(resp,success);
    }
}
